Since the original tech preview release of FastCGI last year, we've been seeing a lot of requests for getting Ruby on Rails running with our FastCGI. Theoretically, since the FastCGI component uses a standard protocol to support FastCGI-enabled applications, this shouldnt be an issue – but, in practice, this is very far from reality. After factoring in setup problems, configuration, and variations in runtime behavior / protocol deviations, every single FastCGI application we've looked at has required quite some effort to support properly.
So, for FastCGI Tech Preview 2, I spent some time researching what it would take to enable Ruby on Rails, resulting in "experimental" RoR support in the TP2 release. It is "experimental" because we did only limited testing, and given our lack of experience with Ruby its very hard to tell whether a real Ruby application will work as expected at this point.
I am confident that the experience can be improved significantly with community testing, and any necessary fixes to both the FastCGI component and Ruby. I am looking forward to any feedback/bug reports that can help us get there – please feel free to leave comments on the blog, or post to IIS FastCGI forums.
Without further ado, these are the 10 steps get RoR working with FastCGI TP2:
Read this first – platform limitations
The steps below can be used to install Ruby on Rails on a Windows Server 2003 operating system, and configure it to work with the Microsoft IIS FastCGI technical preview 2 release. Unfortunately Windows XP does not support the required configuration necessary for the FastCGI TP2 component to run RoR, and Windows Vista's version of FastCGI TP2 uses a different mechanism to run RoR (post on how to get that working in the near future). The initial steps to install Ruby on Rails described here are similar for Windows XP, Windows Server 2003, and Windows Vista.
FastCGI TP2 Installation
1) Download and install FastCGI Technical Preview 2
Download the appropriate TP2 package for your OS, which in this case means either the IIS6 32bit FastCGI or IIS6 64bit FastCGI. You can read more about this on my previous blog post. Here is the synopsis of the install steps:
- Download the appropriate FastCGI TP2 package
- Unzip it to a local directory on your machine
- Use fcgisetup.js to install it:
> cscript fcgisetup.js /install
This will install FastCGI on your machine, and enable us to configure it manually later. We will not be using the automatic configuration support in the installer because we will need some customizations specific for RoR later.
Ruby Installation
2) Download and install Ruby (latest tested version was 1.8.5-22 Final)
3) Install Rails
Open a new command line window, and run the gem installer:
> gem install rails –include-dependencies
4) Download and install RoR IIS extensions
The RubyForIIS.exe package contains the FastCGI client library on which RoR is dependent in order to use its dispatch.fcgi script. During the installation, the installer will ask for the location of the Ruby directory – be sure to point the installer to the directory where you installed Ruby, for example, f:Ruby.
During the installation, you may get an error "Unable to write to file …msvcp7.dll" – press ignore to continue. If you want to double-check that everything went well, open a command prompt, and type in:
> irb <enter>
> require 'fcgi' <enter>
If you see "true", then its installed correctly. If not, re-install and give the right path this time.
5) Fix the Ruby CGI script
This is a workaround for an IIS-specific behavior in Ruby that actually does not work with IIS. Feel the irony. Quick background – NPH, or No Parsed Headers, is a CGI mode of operation in which the CGI program produces a complete response including the http headers, instead of supplying the headers to the web server and letting the webserver manage them. Most of today's webservers, including IIS, manage response headers on their own – for example, IIS enables a number of web server features that modify response headers in order to enable functionality like caching, compression, etc. Ruby's CGI script assumes that IIS always requires NPH, and this of course completely breaks the FastCGI component because it does not even support NPH ๐ The funnier thing is that even IIS CGI does not require NPH, and doesnt use it by default. This is one of the things that totally makes sense to be fixed in a future Rails release to provide a more cohesive experience on IIS.
Open <f:Ruby>libruby1.8cgi.rb, and edit line 559 of the script to remove:
"OR /IIS/n.match(env_table([‘SERVER_SOFTWARE’])".
You can also download the already fixed script if you dont want to do surgery yourself.
Creating a sample Ruby application
At this point, if you followed the instructions above, you should have Ruby on Rails installed and ready to go on your Windows machine. Now, we will create a sample RoR application to use with the FastCGI component:
6) Create a sample Ruby app
Open a command line window, change to a base directory where you want to create your app, and type:
> rails myapp
> cd myapp
> ruby scriptgenerate controller test
This creates the myapp RoR application, and then generates a sample "test" RoR controller. Edit this controller to display some useful stuff by opening appcontrollertest_controller.rb, and pasting the following into it:
class TestController < ApplicationController
def index
render :text=>"The index action"
end
def about
render :text=>"Testing app v1.0"
end
end
Configure the RoR application with IIS and FastCGI
We are almost there, so don't panic. I promise to not exceed 10 steps ๐
7) Create a website for your RoR app
Create a new website on port 81 pointing to the public directory of your rails app, which for me was f:rubymyapppublic:
8) Create the RoR FastCGI handler mapping
Because RoR uses SEF (search engine friendly) urls, it needs to use a wildcard mapping to forward all requests to FastCGI / RoR mapping – unlike PHP, which requires .PHP files to be mapped to the PHP / FastCGI mapping. Because of reliance on wildcard mapping, FastCGI can only be used to run RoR on Windows Server 2003 (since Windows XP's version of IIS doesnt support wildcard mappings). This is the sole reason why this walkthrough is limited to W2k3.
To create the mapping, click the "Configuration" button on the website, and "Insert" the handler mapping to "fcgiext.dll" FastCGI ISAPI handler (which you installed in step 1):
Be sure to clear the "Verify that file exists" checkbox.
9) Create the FastCGI application pool for your website
If you remember in step 1, when we installed the FastCGI TP2 package, we didnt use the installer's support for registering a FastCGI program. This is because RoR requires some custom settings in the FastCGI config file that the installer doesnt surface.
Because of this, we will manually create this configuration by editing the %windir%system32inetsrvfcgiext.ini configuration file (NOTE that for 64bit installations, you will also need to make the same edits to %windir%syswow64inetsrvfcgiext.ini):
[Types]
*:85358523=Ruby
[Ruby]
ExePath=F:Rubybinruby.exe
Arguments=F:Rubymyapppublicdispatch.fcgi
IgnoreDirectories=0
IgnoreExistingFiles=1
QueueLength=1000
MaxInstances=4
InstanceTimeout=30
InstanceMaxRequests=200
– Replace the ExePath with the path to your ruby.exe.
– Replace the Arguments with the path the dispatch.fcgi script inside your application.
– Replace the "85358523" number above with your site id. You could omit this if you are not planning to run multiple Ruby applications on your machine. You can get it from the logging properties of your website:
This configuration shows the several new configuration / behavior features we needed to add to TP2 in order to get Ruby working. This includes support for specifying arguments to the FastCGI executable (per pool), the ability to scope FastCGI extension mappings to a particular site id (so that you can map the same extension to different pools for different sites), and the ability to execute as a wildcard mapping that only processes files that do not exist on disk. More information on all of these later.
10) You are done!
At this point, you should be up and running. Hit up http://localhost:81/test/about, and you should get the RoR response from our test controller.
Please try this out with your real RoR apps, and let me know how it went / what issues you hit. Your feedback will be instrumental in getting to a production quality FastCGI support for RoR in a future release. Feel free to leave comments on this blog, or hit us up at the FastCGI forums on www.iis.net.
Finally, I want to thank Brian Hogan, without whose invaluable help in explaining the workings of Ruby On Rails and how to get it installed on Windows, I wouldn't have been able to get even this far. He has a book on Ruby on Rails coming out soon, and I hope that we can get IIS FastCGI and RoR to play well enough together to be mentioned in it ๐
Mike Volodarsky
By the way, you can find information on how to use IIS FastCGI with PHP here: http://mvolo.com/blogs/serverside/archive/2007/01/31/Turbo_2D00_charge-your-PHP-applications-with-IIS-FastCGI-Technical-Preview-2.aspx.
Anonymous
Hi Mike,
Good to see that IIS is getting some FastCGI tlc. I'll give it a try with some other frameworks as well. I expect this can help quite some developers with pushing/using their favorite framework into an organization.
I've noticed you do not require / use a url rewrite engine to redirect only the appropriate requests to fcgi. So for example, static .js, .css, etc. files could be handled directly by IIS. Are they being handled by the fcgi proces, and is this something we should worry about performance wise?
I think I should revive the ror fcgi installer. Let me see if I can find some time for this.
Thanks Mike!
Mike Volodarsky
Boris,
Glad to see that you are looking at this. Yes, we added a feature to the FastCGI itself to enable it to be “wildcard mapped”, but ignore requests to files/directories that exist and pass them to the static file handler / other handlers. I am not 100% sure whether this completely satisfied Ruby, and welcome any info you might have after playing with it. On IIS7 (my next post for this), we are trying a slightly different approach we external re-writing may be the way to go, and I was planning to build a small RoR helper rewriter module for this purpose.
Also, anything we can do to improve the overall setup / installation process for RoR with the IIS FastCGI will be great as well – looking forward to your feedback …
Anonymous
Hi Mike,
this is great info. Deployment story for the RoR is already somewhat complex, running it all on Windows where I feel a lot more comfortable than on Linux is going to make things a lot simpler for me (and other Windows developers of course).
I am looking forward to the IIS7 version of this article. Do you know if Vista (Ultimate) IIS7 is in any way "inferior" to the (not yet released) "Longhorn" Server IIS7 in the same sense that XP's IIS cannot be used for the setup above? In other words, will the next blog post about IIS7 apply to Vista's IIS?
Mike Volodarsky
Drazen,
Vista’s IIS is effectively identical to the upcoming Longhorn server’s IIS as far as developer APIs, configuration, etc. This is done on purpose so that developers like yourself can start developing for IIS7 now with Vista, and then deploy with Longhorn server.
Now, I can certainly tell you that we are working very hard on Longhorn server’s IIS – but the majority of our work focuses on improving the stability, performance, and security of the server, and enabling production scenarios without changing any of the developer story. Any of the additions will also be synced back to your Vista machine with Vista SP1, so you will get all the improvements on your dev box as well.
So, in other words, the Vista FastCGI RoR post will apply to both Vista and the upcoming Longhorn server.
Thanks,
Mike
Anonymous
Mike, I asked about Wildcard mapping on XP somewhere (can’t remember where) and was told that it was possible with a registry change or maybe some other mod. Are you *sure* Wildcard mapping is not possible on XP’s IIS, and if you do indeed find out that it *is* possible, can you tell us how to do it?
Thanks in advance.
Anonymous
Also, may I make a request/suggestion?
IF you have code that can make Wildcard mapping *viable* on IIS6 by bypassing the ISAPI filter to serve static code, is there any chance you could publish it as support for ASP & ASP.NET?
More specifically, I’d like two ISAPI filters (i.e. ‘asp-wildcard.dll’ and ‘aspnet-wildcard.dll’) that, when used with the Wildcard option on IIS, would respectively load asp.dll and aspnet_isapi.dll when the URL does not map to an existing file, but would bypass the ASP(.NET) ISAPI filter(s) when a static file DOES map the requesting URL. For this to work it would need to load the default document when a static file doesn’t exist allowing the developer to inspect the REQUEST_PATH HTTP Header and then dispatch code however he chooses. This could be also be the lynchpin for lots of great new web frameworks on IIS (as opposed to on Apache…)
If you did this, you would almost completely address the issues I ranted about on my blog [1] regarding IIS6 (but not regarding the timing of IIS7 or most of my issues with ASP.NET). It would also seem to me that you’ve already got 99% the code written and tested and would only need to call the ASP(.NET) ISAPI filters instead of PHP to accomplish this feat?
Oh please, please do consider it… Available next Monday? ๐
[1] http://www.mikeschinkel.com/blog/iis70toolittletoolate/
Anonymous
I want to voice my support for Mike Schinkel's comment (February 22, 2007 6:28 PM) requesting the 2 ISAPI filters for IIS6. Those would be very, very useful for me too. I think he has a great suggestion.
Mike Volodarsky
Mike,
Let's keep this post focused on Ruby on Rails. We can have a conversation in email about the rewriting topics.
To quickly answer your questions – it is not possible to do wildcard mapping on XP / IIS 5.1. Only in IIS6. It IS possible to use asp.net in the mode that you want, by wildcard mapping it, and then using the ASP.NET handler mappings list to determine whether ASP.NET should process the request or whether it should be rewritten in any way / and or sent back to IIS for IIS processing (static file, ASP, CGI, etc). This is done with a custom derivation of DefaultHttpHandler.
ASP does not support wildcard mapping.
But, you can write an ISAPI for IIS6 that does the wildcard mapping and implements the rewriting, much like we did for FastCGI ISAPI in order to support RoR. This again is possible for IIS6+ only.
In IIS7, it is not necessary to wildcard map anything, because you can run as a module (both native one written to the new C++ API or an ASP.NET one) for all requests, do any rewriting you want, and map any handler you want.
Lets discuss the rest in email.
Anonymous
>> So, in other words, the Vista FastCGI RoR post will apply to both Vista and the upcoming Longhorn server.
Great news! I know that Microsoft needs to differentiate the Windows Server offering from the desktop OS like Vista, but hopefully not at the cost of the API changes for developers. I can see now that you’ve taken this into account which is really cool. Thanks.
Mike Volodarsky
Hey, so have any of you guys actually tried to deploy a real RoR application with FastCGI TP2 and these instructions? I cant wait to hear about bugs / success stories so we can take this forward …
Anonymous
I just tried out these steps and so far all is good – thanks for this article! I would add the following to steps:
Step 1) beware that IIS will be stopped during the installation of FastCGI
Step 3) after installing Rails reboot (on my w3k machine the Ruby/Rails env variable wasn't picked up until after the reboot)
Mike Volodarsky
Julia,
Thanks for checking in! What kind of application were you running, if its not a secret?
IIS is indeed restarted during the FastCGI installation, I realize this may be an issue for installing on a production server. But, I wouldn’t recommend doing this in the first place as FastCGI Tech Preview does not have a production license yet ๐ But anyway, thanks for noting.
Good point about #3 – I will add the fact that you need to manually IISRESET after adding the variable so that it is picked up. A full restart shouldnt be required.
Thanks again for posting!
Anonymous
Hi Mike,
I tried out on two test servers, but only the Welcome aboard page could be showed (the static index.html page). When visiting the /rails/info/properties or /test/about, I got a 404 error. I followed exactly these steps.
Thanks in advance.
Mike Volodarsky
James,
Are you getting a Ruby 404 page, or an IIS 404 page?
Be sure that in your handler mapping you cleared the “Verify that file exists” checkbox.
Anonymous
Love the instructions. Got everything setup and working to the point that files that exist due to sent. Any ruby code and it fails. I get a permissions error from FastCGI and when looking at what little logs are there, it says an error with the CGI.parse command (nil.parse). Any advice?
Anonymous
Mike,
Kept getting a 500 Server Error when I accessed
http://localhost:81/test/about
The log/development.log file told me that there was a “Permission Denied” on a tmpsessionsruby_sess* file.
Gave allUsers write access on the tmp folder and it started working.
Thanks for the instructions, very useful!
Mike Volodarsky
Richard,
Try following Pradeep’s workaround, and check your log/development.log file to see if there are any issues.
Pradeep thanks for posting.
Anonymous
Mike,
>> To quickly answer your questions – it is not possible to do wildcard mapping on XP / IIS 5.1. Only in IIS6.
>> …
>> Lets discuss the rest in email.
Okay, but since I’m not heard back from you for over a two weeks… ๐
>> It IS possible to use asp.net in the mode that you want, by wildcard mapping it, and then using the ASP.NET handler mappings list to determine whether ASP.NET should process the request or whether it should be rewritten in any way / and or sent back to IIS for IIS processing (static file, ASP, CGI, etc). This is done with a custom derivation of DefaultHttpHandler.
I’ve never seen a code example on the web of this, and I watch this space like a hawk. Can you (get someone to) present a fully working code sample, ideally something accessible even to people using Visual Web Developer Express?
>> ASP does not support wildcard mapping.
Evidently Scott Guthrie’s post says otherwise?[1]
>> But, you can write an ISAPI for IIS6 that does the wildcard mapping and implements the rewriting, much like we did for FastCGI ISAPI in order to support RoR. This again is possible for IIS6+ only.
No I can’t. I don’t know how to code in C++ and don’t have the patience to learn it either. ๐ But since it would help so many people, and since you guys almost certainly already have 99% of the code, you or your team could write it and offer it to all of us; that’s what I’m asking. BTW, I’m only concerned with IIS6 because as you say IIS7 has a better way.
P.S. Are you aware that your permalinks to comments do not work? I think maybe ASP.NET is overwriting your nice clean numeric IDs. It sure would be nice if you could fix that to make referencing comments on your page easier. ๐
P.P.S. Also, can you add a note next to your comment box indicating people need to use
tags to seperate paragraphs? My comment above looks horrid as I did’t know that was how your system works.
[1] http://weblogs.asp.net/scottgu/default.aspx
Anonymous
Unfortunately, the error is coming from the FastCGI implementation itself and not ruby. Checking its log its crash log is where I found the error regarding a nil object. It looks like it crashes out before Ruby kicks into full gear.
Anonymous
Hi Mike, I'm looking forward to your tutorial on how to use Ruby on IIS7 on my Vista.
In the meantime I'm trying to install Ruby on my W2k3 x64 IIS6 Machine according to your guide but all I get is a Error 500:
"Error 0x80070005 occurred processing request.
Access is denied."
I gave full access to "rubymyapp"-dir for everyone but that doesn't fix the error ๐
The error occurs on "http://…/test/about" as well as on "http://…/some/nonsense"…
Any Ideas?
Sebastian
Mike Volodarsky
Richard,
Can you post the details about this problem to the forums at http://forums.iis.net/1103/ShowForum.aspx?
Here is what we would need to know:
1) Which log file are you referring to?
2) What exactly is the “nill object” error
Thanks,
Mike
Anonymous
The reason for the 0x80070005 Error was FastCGI not beeing able to access the c:ruby… changing the permissions fixed the problem
But now I get another Error:
"FastCGI Handler Extension
Error 0x80004005 occurred processing request.
The FastCGI process exited unexpectedly"
I'm too tired to further investigate that right now
good night
Sebastian
Mike Volodarsky
Mike,
I was actually expecting you to email me ๐ I’ve been also pretty crazed with IIS7 work for LHS beta3 (which is coming out very soon), so I’ve been behind on my blogging and projects. Hopefully it should get better soon so I can spend more time on this.
I do welcome an email discussion around these topics in the meantime though.
Re: scotts post – to clarify – ASP.dll does not support wildcard mapping. ASP.NET does, so you can route ASP requests through ASP.NET. What you cant do is route non-ASP requests through ASP.
When you email me, we can try to work out a list of things, samples or otherwise, that we can do to improve the state of this space. You should be able to figure out what my email address is pretty easily ๐
Thanks,
Mike
Anonymous
I plan on testing this version out in the near future. If all goes well and the community wants the support for it, I will build it into my installer package as an option.
In the mean time if you are having any issues getting this beta version to work properly, take a look at my installer which uses the open source isapi_fcgi.dll ISAPI FastCGI implementation.
Anonymous
Get 500 server Error when I access http://localhost:81/test/about. It seems like the request never reach RoR as the rails application log show no trace of the request. (using WEBRIC server assures the application runs ok)
I can open the applications static index.html, but when i try /rails/info/properties I get FastCGIHandler Extension:Error 0x80004005 occured processing request. The FastCGI process exited unexpectedly.
I have three sites on my server, and the IIS log for the Ruby site show 2007-03-14 10:55:51 127.0.0.1 GET /test/about – 81 – 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727) 200 0 0
Any suggestions?
Mike Volodarsky
BG,
It looks like the Ruby.exe process is failing upon being started. Can you provide the contents of your fcgiext.ini file?
Also make sure that the path to the dispatch.fcgi you are providing to it is correct, and that the application pool identity has read access to the application directory.
Thanks,
Mike
Anonymous
Mike,
Giving NETWORK SERVICE full control over the application directory fixed the problem.
I am now running the site with Integrated Windows authentication to achive Single-Sign-On and use the request.env[“AUTH_USER”] to achive a role based authorization, based on user group belongings in AD.
Thanks,
BG
Anonymous
I followed the instructions (including setting the permissions C:Ruby and putting readwrite on the application directory fixed up everything nice.
It’s worth noting to triple check the INI edits – they did me in :). Once I mapped that stuff right and restarted IIS, it all worked great.
Error reporting is excellent – Rails errors show as they should – not as a 500 error.
Scaffolding works a treat against MySQL 5.
I will be creating a mid-sized application using this, and I’ll be sure to writeup the results here and on my blog.
Nice work Mike! I think you’re my new favorite person :).
Anonymous
mvolo: I was actually expecting you to email me ๐
I did email you, via [1]. You must have missed it, or it didn’t work. ๐ My email is mikeschinkel at gmail dot com.
I’ll be in Redmond at least April 18-19, 2007 for Powershell meeting, and probably a day before and a day after. Any chance we could chat for 30 min while I’m there?
[1] http://mvolo.com/blogs/serverside/contact.aspx
Anonymous
I just ported over an application I built a few months back to see how it would hold up. I integrated the GoogleMaps API and have about 12 different "pages" – all work great and are very responsive. I just wish we could get around the initial spin-up lag :). But I'm just stoked it works. I'll post any and all issues if they arise. My next step is to integrate Amazon web services as part of an article I'm writing; I'll let you know how it goes…
Mike Volodarsky
Rob,
Great to hear. Please keep us posted!
Thanks,
Mike
Anonymous
Hello,
This has reference to your 10 steps mentioned above for running Ruby with IIS.
I am having Windows Xp, wih service pack 2 and IIS 5.1.
Pl. tell me in short, whether i can make those 10 steps work with IIS 5.1 or not.
I have no plans to install IIS 6 at this Stge.
Thanks
Mike Volodarsky
Unfortunately, no ๐ We require wildcard mapping support for Ruby to be set up this way, and this is only present on IIS6+.
You can however run still run FastCGI with applications like PHP on XP / IIS5.1, just not Ruby.
Thanks,
Mike
Anonymous
Hello Mike,
To what extent will you be providing support for developers who want to integrate frameworks like Rails on LHS?
Personal preference would be that one would only have to do configuration, not download & configure external add-ons and mess about with .ini files (this is presuming Rails & Ruby have already been installed by some mechanism, be it InstantRails, .msi, or something else).
Am I correct in assuming that you’re also aiming for a configuration-only support?
That would be, *expletive deleted* great, to put it mildly ๐
Anonymous
Thank you for helping to get a viable RoR on IIS solution into development. I am considering using this method, but need to know whether or not it will support installing applications in virtual directories. I wish to run a ruby app as a sub directory of the default web site alongside WSUS and a couple of other applications (its an app for documenting our servers and monitoring their status.)
Anonymous
Rails rock, runs every where !
But mongrel is best server.
Mike Volodarsky
John,
Have you tried doing this? From the IIS perspective, there shouldnt be a problem – although we have not tested this at this point.
Theoreticaly, FastCGI provides the server variables that RoR should be able to use to allow this to work.
Can you give this a try, and let us know?
Thanks,
Mike
Anonymous
I got the same error
“FastCGI Handler Extension
Error 0x80004005 occurred processing request.
The FastCGI process exited unexpectedly”
I need your help Mike!
Thanks.
Bird
Mike Volodarsky
Bird,
It looks like the FastCGI process you have configured has AVed. This could happen for any number of Ruby-specific reasons, like invalid access permissions, or invalid configuration, etc – you’d really need more information to move forward.
Check the “application” event log for details of the AV, or the Ruby log if one exists.
It may be worth verifying that you can run ruby.exe from command line without an error, to eliminate ruby setup issues.
If this doesnt help you, try monitoring the ruby.exe process with process monitor to see what happens that leads to a crash. Running ruby.exe under the debugger may also help.
Thanks,
Mike
Anonymous
Mike,
Ruby didn’t run in the process monitor
Thanks,
Bird
Anonymous
Mike ,
The contents of my fcgiext.ini file
[Types]
*:71874619=Ruby
[Ruby]
ExePath=C:rubybinruby.exe
Arguments=F:webruby on railsmyapppublicdispatch.fcgi
IgnoreDirectories=0
IgnoreExistingFiles=1
QueueLength=1000
MaxInstances=4
InstanceTimeout=30
InstanceMaxRequests=200
Thanks,
Bird
Anonymous
Mike,
I find the reason may be the site permissions
Anonymous
It is nice to see that IIS has a way to accommodate RoR web apps.
I am not to much acquaint with IIS mainly because Apache + Mongrel + Rails combination is more flexible to me and I not even try to engage the IIS.
Nevertheless I embrace your effort to enable RoR for the IIS in an easy and clean way. I look forward to see the final painless solution.
Anonymous
There’s no way to make the rails application run inside a virtual directory!, at least not without any documentation:
FastCGI Handler Extension
Error 0x80070585 occurred processing request.
Invalid index.
If we try to run the application on a web server it seems fine but we need to use our https certificate so this is not an option.
The people interested may come from other technologies or platforms, in my personal case from *NIX. Please consider this and help us with more documentation. =)
Anonymous
In Step 5 where you modify the Ruby CGI.rb, what bug are you actually trying to “fix” here? If you are referring to the issue with the HTTP status codes not properly being passed through from Ruby on Rails, the bug is not in Rubies CGI implementation (because it works just fine under webrick server) the bug is in rails itself. ApplicationController base.rb render_text method sets @response.headers[‘Status’] upper case but CGI looks for lowercase ‘status’. If you look in the webrick HttpResponse class you will see they do a downcase on the indexer key of the headers hash. Its just a bug in Rails specifically and not Ruby, IMHO.
Mike Volodarsky
bheinz,
The issue we had to mitigate with this fix is that CGI.rb automatically detects when its hosted under IIS, and behaves as a “NPH” script. With FastCGI, this actually breaks the server because we dont support the NPH mode – so the fix disables this special casing and lets Ruby behave as a normal CGI script. I am not sure whether CGI.rb is part of Ruby or Rails, but its a necessary fix in order to enable RoR to work.
Thanks,
Mike
Anonymous
I followed the steps exactly and for some reason it does not work. It gives me an IIS error mage. I don’t know where to look next. Could someone give me some clues?
I tried it twice as well. Used the exact versions and everything. I have no idea what is going on.
Brand new machine with a fresh install of Windows SBS 2003
Anonymous
I posted here yesterday, however, I got a step further. I did not notice the “Be sure to clear the “Verify that file exists” checkbox.”
I did that and now I can connect to the page, however, I am getting a 500 error:
FastCGI Handler Extension
Error 0x80070585 occurred processing request.
Invalid index.
Any help would be appreciated
Anonymous
Installed Ruby, RoR IIS extensions and followed the rest of the instructions. As soon as I had added full control to the network service on the myapp directory, everything worked as a charm. I’m gonna try some real applications in the days to come …
Mike Volodarsky
Dirk,
“Network Service”, or identity of the IIS application pool if you have changed it, needs to have Read access to the application root (Full / write / change access is not required by IIS and shouldnt be granted for security reasons). Also, “Network Service” or your apppool identity needs to have Read access to the directory with Ruby.exe.
I am not 100% sure what permissions Ruby.exe itself requires beyond the Read access. It will be executed with the same identity that the IIS application pool runs under, so you would need to grant any required permissions to it.
Thanks,
Mike
Mike Volodarsky
Nick,
Be sure that your fcgiext.ini configuration is correct, and uses the right site number if it specifies one.
Thanks,
Mike
Anonymous
Hello, I’m trying to get things working on a W2K3 but it doesn’t work!
The error message I get is:
“…
Error 0x80070102 occurred processing request.
The FastCGI process exceeded configured activity timeout”
I checked the cgi.rb and the fcgiext.ini and they are correct (the name and id of the site are the same: Ruby – 85358523).
Don’t know what else to check or do!
Please help me!!
Thanks,
Luca
Mike Volodarsky
Luca,
Can you use the Process Explorer tool (or task maanger) to confirm that “Ruby.exe” is starting when you make a request to the ruby app? Be sure its “ruby.exe”, not “rubyw.exe” or any other process (like notepad.exe, that wont work either ๐ ).
The error usually means that either you are not starting the right process which doesnt correctly communicate over FastCGI, or perhaps your Ruby script is taking a long time to do anything and tripping up the activity timeout.
If you are sure Ruby.exe is starting and doing work, you can adjust the activity timeout up – set the “ActivityTimeout=T” in your fcgiext.ini pool definition where T is seconds.
Thanks,
Mike
Anonymous
Hi,
Thanks for your detailed instructions. I am having a strange problem with getting my RoR app to work properly with W2K3 and IIS 6.0.
The app works but only for one of my controllers. I’ve given permissions to all users and double checked the configuration files.
MySql is working because I can create records with the one controller that works. Also, the application functions properly if I boot it locally with Webrick or Monrel.
Any Advise would be very helpful,
Thanks,
– Matt
Anonymous
I’ve checked the task manager and the ruby.exe process is running but it stops after a few seconds and the error message this time is different:
“…Error 0x80004005 occurred processing request.
The FastCGI process exited unexpectedly”
the most recent release of ruby AND rails are installed, as is the FCGI extension for IIS 6.
Anonymous
hello Mike
“sorry for my english. I have translate from google”.
I AM FROM ROME ITALY.
I have followed your instructions and all it has gone well.
I wanted to ask to you: if I must realize two applications, on same web server, what I must make, and as I must modify fcgiext.ini?
thanks and I hope to me it are explained!!
Ciao
Aldo Italy Rome
Mike Volodarsky
Luca,
This sounds like a bug in Ruby that is causing the Ruby process to go away prematurely. It may also be a Ruby configuration that causes Ruby to only process 1 request before the process goes away – you may need to ask in RoR forums.
If so, you may need to set this to a number higher then instanceMaxRequests in FastCGI configuration (or lower instanceMaxRequests to be under the Ruby max requests).
Thanks,
Mike
Mike Volodarsky
Matt,
What is the error you get for your other controllers?
Thanks,
Mike
Anonymous
Has there been any progress on an IIS7 installer guide? I tried installing on Vista Ultimate last night and I think I’m getting somewhere, but I was getting a “General Silliness” error (that should have been fixed in the TP2 release, but maybe I need to reboot!). Any help with setting up IIS7 is appreciated. FWIW I have PHP running under this FastCGI on the same box and that’s fine. Maybe I’m expecting too much to have PHP and RoR on the same web server…
Derek
Anonymous
Thank you for the intro on getting RoR running on W2K3. I believe this will be a “killer app” if it works well. There are a lot of former ASP.NET developers switching to RoR that know little about setting up Linux server environments and they will be happy if they can continue running Windows on the server side.
Right now it looks like the JRuby guys have managed to create a dead simple deployment scenario for RoR-apps (to be able to run them in the Java server environment). I sincerely hope that something similar will appear for W2K3/IIS. When will that John Lam guy be done with IronRuby so that we can do one-line deplyment of Ruby on Rails apps to IIS servers? ๐
Anonymous
After posting my post about Being a Better Developer , and needing info about Ruby on Rails and IIS (since
Anonymous
hello Mike, in attended of the answer (you see over), I wanted to ask to you if it is normal school that with fastcgi on IIS the performance seems to get worse.
Aldo Rome Italy
Mike Volodarsky
Hi Aldo,
We havent looked into Ruby performance extensively yet, although I have observed poor performance coming from Ruby.exe itself. I heard that it may be due to Ruby not running in “production mode”, which I believe is controlled by environment variables you set on the box.
You may be able to get more ideas on Ruby forums.
Thanks,
Mike
Anonymous
Mike, I’m having issues here…
My first error was similar to others:
FastCGI Handler Extension
Error 0x80070585 occurred processing request.
Invalid index.
I originally had named the site “Rails”. I renamed it Ruby (and changed fcgiext.ini to reflect the name change) and that error went away. Now I’m getting…
FastCGI Handler Extension
Error 0x80004005 occurred processing request.
The FastCGI process exited unexpectedly
I’ll go look for ways to address that second error (unless you’ve determined the cause since it was last asked), but would you mind explaining why the it doesn’t work to have the site named “Rails” with the fcgiext.ini saying:
[Types]
*:10740288=Rails
That seems odd to me. The right side of that equal sign is supposed to be the IIS site name, right?
Anonymous
Great how-to. I did it with ruby 1.8.6-25 and the golive release of fast cgi extension. Worked great.
All the other how-tos I found out there included installing some url rewriters and pretty heavy code changes.
I was able to set mine up as a virtual directory under my default site (which uses PHP, isapi currently, maybe fastcgi soon). I just added the fastcgi handler to the virtual directory and not the site root. I also had to edit the default routes in config/routes.rb and add the name of the virtual directory:
ie
map.connect ‘/:controller/:action/:id.:format’
map.connect ‘/:controller/:action/:id’
becomes
map.connect ‘myapp/:controller/:action/:id.:format’
map.connect ‘myapp/:controller/:action/:id’
where myapp is the name of the virtual directory, not your application (although you probably will name the virtual directory the same as your app)
You are limited to only one application this way (you can create others as separate sites still) because you have to route sites, not directories, to the app roots in the ini file.
Anonymous
Iam getting the below error.if u know how to solve this problem pls help me
FastCGI Error
The FastCGI Handler was unable to process the request.
Error Details:
* Could not find entry for “(null)” on site 802735 in [Types] section.
* Error Number: 1413 (0x80070585).
* Error Description: Invalid index.
HTTP Error 500 – Server Error.
Internet Information Services (IIS)
Mike Volodarsky
Hi Shiva,
Can you post this problem on the FastCGI forums – http://forums.iis.net/1103.aspx? We can help you there.
Thanks,
Mike
Anonymous
Nice!
Anonymous
Hi Mike,
I can’t seem to get this working with a default route. I have mapped ” to :controller => ‘test’, and deleted index.html, however IIS is returning a “Directory Listing Denied” error, rather than passing the request over to the FastCGI process.
I have made sure that IgnoreExistingDirectories is set to 0 in the fastcgi config.
visiting /test/index works just fine.
Anonymous
what is a site id? and how do i find my site id”?
Anonymous
ๆ่ฆ
็ปๅไฝๆๅๆไธชๆๅนด๏ผไธ้ขๆฏไธคๅจ็ๆจ่๏ผๅ ฑๆ9็ฏๆ็ซ ๏ผ ASP.NETAJAXๅSharePoint
็จC#็ผๅVista็Gadget
.NETFramework็ผๅนดๅฒ
…
Anonymous
I want to upgrade my iis6 to iis7 for my windows2003 os.is it possible?
Anonymous
Everything seems to be working well when using rails and weborb as a backend for a flex app. Just followed the steps here and things seem to be working well straight away. Thanks!!
Anonymous
When i followed the steps provided (using 2003 and FCGI) i always wind up getting a fastCGI error: The FastCGI process exited unexpectedly. So i checked out rick.james information regarding this issue at http://blogs.iis.net/rickjames/archive/2007/10/16/fastcgi-debugging-quot-the-fastcgi-process-exited-unexpectedly-quot.aspx.
after testing i still get the same old results though. Just curious if anyone else had this issue before in the past or present and might be able to provide some information
Diego
Hey Matthijs,Thanks for the input, let us know what you think after using the tool a bit, feedback is aywlas helpful. You note some good points here. I think what we are going to do down the road is write a more real world example than the simple one we already posted (which was just meant as a very basic introduction) and that example would include some code similar to what you have above.Gabe
Anonymous
Hmmm I wonder if with some armtwisting the FCGI handler could talk to Django….
Anonymous
Well, never mind. seems my problem stemmed from a problem with a gem that was installed. Upon fixing the gem issue things seemed to work.
It would be great if fastCGI showed a good error message instead of generic messages about it exiting the process. Debugging can be a pain sometimes…
Thanks for the article
Anonymous
Very interesting, specially working in IIS
Anonymous
Might sound trivial and obvious, but to set the environment (Development, Production), add to the INI file:
EnvironmentVars=RAILS_ENV:production
Anonymous
Hi Mike:
I just read your article, and I tried to dollow the instructions step by step as indicated, however since the begining I have troubles: When trying to install the FastCGI TP2, I got an error that indicates me:
fcgisetup is not a valid Win32 application
I tried in to installed in both ways:
1- By typing cscript fcgisetup.js /install ( as you mentioned in the article)
2- By typing fcgisetup.js /install ( as it is described in the appended readme file of the FastCGI TP2 zip package.
Do you have an idea of what’s happening here?
Mike Volodarsky
Hi Carlos,
Sounds like you are downloading an x64 version for an 32-bit operating system. Be sure to download the 32-bit version.
Thanks,
Mike
Anonymous
hey I always wanted to find out more about plr articles.
Anonymous
Hi Guys .. I’m Know this is a stupid ask … but i think i ask here…
What should i install on Windows Server 2008? DNS+IIS+MYSQL+FASTCGI+Ruby on RAils+SSH+Capistrano or?
Schould i need install Active Directory??? or no`??
Can anybody recommend a book with pratices.. thanksss…
..Thankss guys
Anonymous
I have an interoperability demo that I’m working on, so I’m setting up Ruby so that I can connect via
Anonymous
I have a question .. i tried with this steps and it doenst work .. ๐ .. i dont know more or can you update the information with the newest Version on Windows Server 2008 (FINAL VERSION) ….
Mike Volodarsky
Albert,
This post is about Windows Server 2003. WS08 has some additional requirements.
If I find some time, I’ll blog about it in the future. In the meantime, see if this works for you: http://wiki.rubyonrails.org/rails/pages/HowToConfigureIIS7.
Thanks,
Mike
Anonymous
Hellloooooooo thanks for this great guide, i got it working! HURRAY!
unfortunately i ran into the same problem as mr. mike has posted last year. Copy&Paste:
Hi Mike, I can’t seem to get this working with a default route. I have mapped ” to :controller => ‘test’, and deleted index.html, however IIS is returning a “Directory Listing Denied” error, rather than passing the request over to the FastCGI process. I have made sure that IgnoreExistingDirectories is set to 0 in the fastcgi config. visiting /test/index works just fine.
Is it possible to fix that, or do you know a way to do it?
Anonymous
Hi Mike, I am trying to run rails on WS08 but I cannot get it to work. I tried the rails wiki steps. I keep getting a Internal error 500, c:rubybinruby.exe – The FastCGI process exited unexpectedly. Any ideas to what is wrong? I can run Webrick and create sites and so on so I guess the problem is in configuring IIS7?
jbliss
Thanks, Mike! After following these steps, when I go to http://localhost:81/test/about, I get:
FastCGI Error
The FastCGI Handler was unable to process the request.
Error Details:
* The FastCGI process exited unexpectedly
* Error Number: -2147467259 (0x80004005).
* Error Description: Unspecified error
HTTP Error 500 – Server Error.
Internet Information Services (IIS)
What did I screw up?
Anonymous
hi ๐ i had some problems getting this to work but it seems, setting execute permissions on C:WINDOWSsystem32inetsrvfcgiext.dll/ini as well as the ruby folder and the app folder worked for me
it’d be really nice to see an updated version of this article that uses the fcgi rtm and
http://www.codeplex.com/RORIIS
Anonymous
If you ever tried to set up Ruby on Rails (RoR) on IIS 7.0 with FastCGI you have probably noticed that
Anonymous
I am posting this as I see others have had the same issue, but don’t see an answer to their specific issue.
1) If I use script/server, everything is fine for everything on the site, so seems to be an IIS/FastCGI issue.
2) If I try go to the root of the site, I get a “Directory Listing Denied
This Virtual Directory does not allow contents to be listed.”
3) If I go to any sub-page … say /featured … it works fine, every singe page works as expected except the root’d document.
Has anyone found a solution to this issue? I’ve been searching for a few days now and haven’t found an actual answer to this specific issue.
Thanks!
Anonymous
I posted this yesterday, but don’t see it on here as of yet, sorry if it does post and we end up with dupe posts.
1) If I run the WEBrick application, the website performs fine, including the root web page.
2) All pages running off IIS and ROR appear fine except the page that is in the root directory.
3) The root directory produces a “Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
”
4) Nothing in the logs for either ROR or IIS points me to anything specific.
5) I do see other people have had this issue, but haven’t found a resolution to the issue, any suggestions/hints?
Thanks
Anonymous
Mike,
do you already have the Vista/Longhorn tutorial? I’m really lost here…
Anonymous
I followed the steps here and apart from the permission problems it all worked fine. After granting everyone read/write to the tmp folder under my myapp folder, and giving the IWAM account permissions to my ruby folder, I then got errors about sqlite3. I have posted the fix in this post http://rubyforge.org/tracker/?func=detail&atid=1044&aid=22703&group_id=254
Anonymous
Hi, im having the “The FastCGI process exited unexpectedly” error message, i’ve already assign Full Control to NetworkService account and also make sure that the path to the dispatch.fcgi it’s correct. Any other suggestion, im running IIS7 on Vista SP1.
Anonymous
Assign Full Control to NetworkService account
I've cleared this 500 error to assign Full Control to 'Everyone'.
Anonymous
Error Details:
* The FastCGI process exited unexpectedly
* Error Number: -2147467259 (0x80004005).
* Error Description: Nieokreลlony blad. (english -> Unknown error)
What is the reason of it? Anyone know?
Anonymous
what is a site id? and how do i find my site id”?
someone please respond to this! I imagine it has to do with the url?
How do you link the app you just setup following the above steps to a URL?
Anonymous
this is what I’m getting when I install. Any ideas?
FastCGI Error
The FastCGI Handler was unable to process the request.
——————————————————————————–
Error Details:
Unknown property “InstanceTimeout” present under section “Ruby” in config file.
Error Number: 13 (0x8007000d).
Error Description: The data is invalid.
Anonymous
Stephen Hare: in your C:WINDOWSsystem32inetsrvfcgiext.ini, change InstanceTimeout to ActivityTimeout.
Anonymous
Hi,
I’m referring this link to install ruby on rails in windows server 2003 having IIS6.0.i have installed ruby on rails in windows as per above steps, but when i create rail application using command > rails myapplic , then the following files are misssing under public folder of the rail application ,they are dispatch.rg,dispatch.cgi and dispatch.fcgi.I tried to reinstall ruby and rail application, but these files are not creating under public folder.
Can you suggest me the steps to proceed with the configuration.I really needs to install it on windows server 2003.
Anonymous
Linson,
I am having the same issue, no dispatch files are being created. I have yet to find out what I missed.
If you resolved this please post.
Anonymous
I got the same issue with Linson and Jay. IIS6 on w2k3. Missing dispatch files.
Anonymous
@Ed, @Linson and @Jay
Rails 2.3+ no longer contains the dispatch files by default. You need to run:
rake rails:update:generate_dispatchers
Anonymous
The issue I’m now having (after giving Network Service permissions) is that the FastCGI process crashes.
I get the default RoR “We’re sorry, but something went wrong” page.
fastcgi.crash.log looks like the following:
[12/Feb/2010:19:24:07 :: 3304] starting
[12/Feb/2010:19:24:07 :: 3304] Ignoring unsupported signal USR1. (**SEVERAL OF THESE SPAM DOWN THE PAGE **)
[12/Feb/2010:19:24:07 :: 3304] Ignoring unsupported signal HUP. (** OCCASSIONALLY ONE OF THESE **)
Anonymous
Ensure you have give NEWORK SERVICE Full Control access to tmp and log in your app. Ensure sqlite3.dll/exe/def is in system32. Doing that allowed all NEW apps to run. My existing app (the one I’m doing this for) still has FastCGI crash before ruby is run.
Anonymous
Above was fixed by moving sqlite dll etc to system32. Still can’t get rails to find static images in the public/images folder. And the root/fallback route doesn’t work. I get an error stating that directory listings aren’t permitted.
Anonymous
thank u man
Anonymous
It can be a good discussion here
http://minimalbugs.com/questions/how-to-install-ruby-on-rails-on-windows
Anonymous
Wonderful article!
To run Ruby on Rails under IIS 7 I would also suggest Helicon Zoo – http://www.helicontech.com/zoo/
Anonymous
your post is very good regarding SBS SUPPORT .its useful for every one.
Anonymous
wow! nice one and so so great information that can’t even handle that much ๐ keep it up dude
ROR Development
Your posts are so cool. Please continue this good work.
Book Publishing
This is a wonderful article for get ruby on rain on window with IIS.
It will helps a lot to developers of ruby on rails,
ruby in bite sized chunks
Hiya only just started scripting with ruby so I am quite a bit
of a newbie! But fortunately found your site very helkpful
and beneficial. Thanks!
Ruby On Rails Server | fleetgpstrackingsoftware.com
[…] 10 steps to get Ruby on Rails running on โฆ โ Since the original tech preview release of FastCGI last year, we’ve been seeing a lot of requests for getting Ruby on Rails running with our FastCGI. […]